package info.gridworld.actor;

import info.gridworld.grid.Location;

import java.util.ArrayList;

public class RockHound extends Critter {
	
	
	
	@Override
	public void makeMove(Location loc) {
		removeRocks();
		super.makeMove(loc);
	}
	

	public void removeRocks() {
		
		ArrayList<Location> locations = getRockLocations();
		for(Location loc : locations) {
			getGrid().remove(loc);
		}
	}
	
	private ArrayList<Location> getRockLocations() {
		
		ArrayList<Location> locations = new ArrayList<Location>();
		
		for(Location loc : getGrid().getValidAdjacentLocations(getLocation())) {
			Actor actor = getGrid().get(loc);
			if(actor != null && actor instanceof Rock) {
				locations.add(loc);
			}
		}
		return locations;
	}

}
